/*
 * @Author: your name
 * @Date: 2021-01-14 15:05:08
 * @LastEditTime: 2021-01-14 16:50:47
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \carlist\src\components\OfficialList\index.js
 */
import React, { Component } from 'react';
import {connect} from "react-redux"
import { bindActionCreators } from "redux";
import * as carAction  from "../../store/action/cars"
class OfficialList extends Component {
    
    getMaketList=(MasterID,i)=>{
        this.props.getMakeListById(MasterID);
        this.props.open()
    }
    render() {
        let {list} = this.props;
        console.log(list)
        return (
            <ul>
                {
                    list.map((v,i)=>{
                        return (
                            <li key={v.MasterID} onClick={()=>{this.getMaketList(v.MasterID,i)}}>
                                <p>
                                    <img src={require("../../static/nb.png")} alt="" data-src={v.CoverPhoto}/>
                                </p>
                                <span>{v.Name}</span>
                            </li>
                        )
                    })
                }
            </ul>
        );
    }
}

const mapStateToProps = (state) => {
    return {
        ...state.cars
    }
}

const mapDispatchToProps = (dispatch) => {
    //bindActionCreators
    //将action贺dispatch组合---生成mapDispatchToProps所需要的内容;
    //一种简写mapDispatchToProps的方式;
    return bindActionCreators(carAction,dispatch)
}

export default connect(mapStateToProps,mapDispatchToProps)(OfficialList);